package cn.tonyandmoney.warescanapp.socket

import io.reactivex.functions.Consumer
import org.jetbrains.anko.AnkoLogger
import org.jetbrains.anko.info

/**
 * Created by niantuo on 2018/4/1.
 * 捕获异常
 */
class RxConsumer<T>(private val callback: (T) -> Unit) : Consumer<T>,AnkoLogger {

    override fun accept(t: T) {
        info("accept: $t")
        try {
            callback.invoke(t)
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }
}